/*
 * @Date: 2025-03-28 09:25:41
 * @Auth: 873768511@qq.com
 * @LastEditors: 463997479@qq.com
 * @LastEditTime: 2025-09-10 17:35:23
 * @FilePath: \corpus\src\pages\catalogue\detail\hooks\index.ts
 */

import { useAntdTable, useRequest } from 'ahooks';
import { createContainer } from 'unstated-next';
// import {
//   modelDetail
// } from '@/services/modelCheck';
import { useLocation } from '@umijs/max';

import { getDetail } from '@/services/ant-design-pro/resource';
import { useState } from 'react';

export default createContainer(() => {
  const [modalVisible, setModalVisible] = useState(false);
  const location: Record<string, any> = useLocation();

  const id = location?.state?.id ? location?.state?.id : '';

  const getTableData = useAntdTable(
    async ({ current, pageSize }) => {
      // const res = await myModelColumns({
      //   currentPage: current || 1,
      //   pageSize: pageSize || 10,
      //   irsCode: query.irsCode
      // })
      // return {
      //   list: res?.data?.list || [],
      //   total: res?.data?.totalItem || 0,
      // };
      return {
        list: [],
        total: 0,
      };
    },
    {
      defaultPageSize: 10,
      defaultCurrent: 1,
      manual: true,
    },
  );
  const detailsData = useRequest(async () => {
    const res = await getDetail({ catalogId: id });

    return res.data;
  });
  return {
    detailsData,
    getTableData,
    modalVisible,
    setModalVisible,
  };
});
